#!/bin/sh

. /opt/ohpc/pub/compiler/intel/composer_xe_2013_sp1.2.144/bin/compilervars.sh intel64
. /opt/ohpc/pub/mpi/impi/4.1.3.048/bin64/mpivars.sh

exe=../src/mini_dft
val=./validate_minidft.py
in=./single-node.in
out=./single-node.out
err=./single-node.err
log=./single-node.log

num_ranks_per_node=8
num_nodes=4
num_threads=4
num_iterations=3

if [ ! -f $exe ]
then
  echo ERROR: $exe file does not exist
  exit
fi

export OMP_NUM_THREADS=$num_threads

rm -f $out $log $err

for i in $(seq 1 $num_iterations)
do
  for j in $(seq 1 $num_nodes)
  do
    r=$((j*num_ranks_per_node))
    srun -N $j -n $r $exe -in $in >$out 2>>$err
    $val $out >>$log
  done
done

grep "Benchmark_Time:" $log
